package team.sun.sss.controller.extra;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;
import team.sun.sss.dao.extra.ChangeWorkDao;
import team.sun.sss.pojo.changework.ChangeWork;

import java.util.List;

@Controller
public class ChangeWorkController {
    @Autowired
    ChangeWorkDao changeWorkDao;

    //跳转页面
    @GetMapping("/change_index")
    public String changeIndex(){
        return "extra/change_index";
    }

    //查询换班表
    @GetMapping("/get_change_work")
    @ResponseBody
    public List<ChangeWork> selectChangeWork(){
        return changeWorkDao.selectChangeWork();
    }

    //审核按钮
    @GetMapping("/examine/{id}")
    @ResponseBody
    public void examine(@PathVariable(name = "id") int id){
        ChangeWork changeWork = changeWorkDao.selectChangeWorkById(id);
        changeWorkDao.updateChangeWork(changeWork);
        changeWorkDao.updateExtraStaff1(changeWork);
        changeWorkDao.updateExtraStaff2(changeWork);

    }

}
